package cn.frh.feign;

import cn.frh.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getByUserId(Long id) {
                //托底数据
                return new User(-1l,"无此用户","用户服务不可用");
            }
        };
    }
}
